<%@page import="java.io.* , java.util.*, java.sql.*,  com.myapp.struts.dao.*, com.myapp.struts.beans.*"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Schedule Creation</title>
        <link href="../../../../css/cms.css" rel="stylesheet" type="text/css">
        <script language="javascript" type="text/javascript">
            function Validate()
            {
                var index1=document.scheduleform.schedulename.selectedIndex;
                if(index1<=0)
                {
                    alert("Please Select Schedle Name....");
                    document.scheduleform.schedulename.focus();
                    return false;
                }
                var index2=document.scheduleform.schno.selectedIndex;
                if(index2<=0)
                {
                    alert("Please Select Schedle Level....");
                    document.scheduleform.schno.focus();
                    return false;
                }
            }
        </script>
    </head>
    <body bgcolor="#D3F1D5">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
                <td width="878" rowspan="12" >
                    <form action="../../../../ScheduleMapper" method="post" name="scheduleform" onSubmit="return Validate()">


                        <%
            ScheduleDao sd2 = new ScheduleDao();
            System.out.println("calling maxvalue method");
            String code = sd2.maxValue();

                        %>
                        <table width="543" border="0" align="center" cellpadding="0" cellspacing="0" style="border-right: #000000 1px solid;
                               border-top: #000000 1px solid; border-left: #000000 1px solid;  border-bottom: #000000 1px solid; font-size: 9pt; color: #000000; font-family: Arial;">
                            <tr>
                                <th height="26" colspan="2" align="center">Enter Schedule Details</th>
                          </tr>
                            <tr>
                                <td>Schedule Number</td>
                                <td width="287"><input name="scheduleno" readonly value="<%=code%>" type="text" size="40" maxlength=20 /></td>
                            </tr>
                            <tr>
                                <td >Schedule Name</td>
                                <td ><select name="schedulename">
                                        <option></option>
                                        <option>assets</option>
                                        <option>liabilities</option>
                                        <option>income</option>
                                        <option>expenditure</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>subschedule Level</td>
                                <td><select name="schno" id="schno" >
                                        <option value=" " selected="selected"> </option>
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                    </select></td>
                            </tr>
                            <tr>
                                <td height="24" colspan="2" align="center" valign="middle"  ><input name="Submit" type="submit" class="tabledata" value="Submit" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            </tr>
                        </table>
                    </form>


                    <table width="545" border="0" align="center" cellpadding="0" cellspacing="0" style="border-right: #000000 1px solid;
                               border-top: #000000 1px solid; border-left: #000000 1px solid;  border-bottom: #000000 1px solid; font-size: 9pt; color: #000000; font-family: Arial;">
                        <tr>
                          <th height="27" colspan="3" scope="col">List of Schedules</th>
                        </tr>
                        <tr>
                            <th width="170" height="23" scope="col">Schedule Name</th>
                          <th width="161" scope="col">Sub Schedule 1</th>
                            <th width="214" scope="col">Sub Schedule2</th>
                        </tr>
                        <%
            ScheduleDao shd = new ScheduleDao();

            ArrayList al = shd.list();
            if (al != null) {
                Iterator itg = al.iterator();
                while (itg.hasNext() == true) {
                    ScheduleBean shb = (ScheduleBean) itg.next();
                    String Schedule_Name = shb.getSchedule_Name();
                    String SubSchedule1 = shb.getSub_Schedule1();
                    String SubSchedule2 = shb.getSub_Schedule2();
                        %>
                        <tr>
                            <td><%=Schedule_Name%></td>
                            <td><%=SubSchedule1%></td>
                            <td><%=SubSchedule2%></td>
                        </tr>
                        <%}
                                     }%>
                    </table>                    
    </td>
            </tr>
        </table>
</body>
</html>
